<template>
  <div>
    <el-table
    :data="tableData"
    stripe
    style="width: 100%">
    <el-table-column
      type="index"
      label="序号"
      width="130"
      >
    </el-table-column>
    <el-table-column
      prop="realname"
      label="访问人真实姓名"
      >
    </el-table-column>
    <el-table-column
      prop="method"
      label="访问方式">
    </el-table-column>
    <el-table-column
      prop="content"
      label="访问路径">
    </el-table-column>
    <el-table-column
      prop="logTime"
      label="访问时间"
      :formatter="dateFormat">
    </el-table-column>
  </el-table>
  <div class="pagination">
    
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[6, 8, 10, 12]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
  </div>
</template>

<script>
import {get,post} from '@/utils/request'
export default {
  data() {
    return {
      tableData: [{
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }, {
          date: '2016-05-04',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1517 弄'
        }, {
          date: '2016-05-01',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1519 弄'
        }, {
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1516 弄'
        }],
        currentPage:1,
        page:1,
        pageSize:12,
        total:10,
    };
  },
  computed: {},
  methods: {
    handleCurrentChange(val) {
        this.currentPage = val;
        this.getAllLog();
      },
    async getAllLog(){
      let data = {
        page:this.currentPage,
        pageSize:this.pageSize
      };
      let res = await get('/baseLog/pageQuery',{...data})
      this.total = res.data.total
      this.tableData = res.data.list
      // console.log(res);
    },
    handleSizeChange(val) {
        this.pageSize = val;

      // 将当前页数重置到第一页
      // this.currentpage = 1;
      this.getAllLog();
      console.log(`每页 ${val} 条`);
      },
      
      dateFormat(row,column){
        const date = new Date(row[column.property])
        return date.getFullYear() + '/' +
        date.getMonth() + '/' +
        date.getDate() + '  ' +
        date.getHours() + '时' +
        date.getMinutes() + '分' +
        date.getSeconds() 
    }
  },
  created() {
    this.getAllLog();
  },
  mounted() {},
};
</script>
<style scoped>
</style>